import {refreshToken} from '@/api/commonApi'
import {clientId, clientSecret, env} from '@/config/config'
import cookie from '@/util/cookie'
export default {
    time: 3600000,
    async refreshToken () {
        var authToken = cookie.get('authToken')
        var params = {             
            refresh_Token: (JSON.parse(authToken)).refresh_token,
            clientId: clientId,
            clientSecret: clientSecret
        }
        var res = await refreshToken(params)
        cookie.set('authToken', decodeURIComponent(JSON.stringify(res)), 100)	
    },

    refreshLoop () {
        setTimeout(async () => {
            await this.refreshToken()
            this.refreshLoop()
        }, this.time)
    }
}